package com.spider.utils;

import java.io.IOException;
import java.net.URLEncoder;

import junit.framework.TestCase;

import org.apache.http.client.ClientProtocolException;
import org.junit.Test;

public class HTTPUtilsTest extends TestCase
{
	/**
mp3的下载地址
http://ok.94007.com:8089/lfkd4/mp3/beijingde.mp3

swf的下载地址
http://ok.94007.com:8089/lfkd4/swf/keainv.swf
	 */
	@Test
	public void test(){
		String result = HTTPUtils.getResponseByURL("ed2k://|file|%E7%96%AF%E7%8B%82%E7%9A%84%E9%BA%A6%E5%85%8B%E6%96%AF%EF%BC%9A%E7%8B%82%E6%9A%B4%E4%B9%8B%E8%B7%AF.HD1280%E8%B6%85%E6%B8%85%E4%B8%AD%E8%8B%B1%E5%8F%8C%E5%AD%97.mp4|2622295400|22F0FA3529900B8A4AA5E6E28EBEF29F|h=PEPEGLT3MS3OM45EPQJAKELIM4VNC3N3|/");
		System.out.println(result);
	}
	public void getHTMLByURL()
	{
		HTTPUtils.getHTMLByURL("http://www.qq190.com/zj/22489.shtml");
	}
	public void getHTMLByURLProxy()
	{
		HTTPUtils.getHTMLByURL("http://train.qunar.com/qunar/stationtostation.jsp?format=json&from=%E5%8C%97%E4%BA%AC&to=%E6%AD%A6%E6%98%8C&type=null&date=20121231&ver=1356268586157&ex_track=&cityname=123456&callback=XQScript_5","172.16.251.58",3128);
	}

	public void getHTML()
	{
		try
		{
			HTTPUtils.getHTML("http://dynamic.12306.cn/otsquery/query/queryRemanentTicketAction.do?method=queryLeftTicket&orderRequest.train_date=2012-12-31&orderRequest.from_station_telecode=BJP&orderRequest.to_station_telecode=WHN&orderRequest.train_no=&trainPassType=QB&trainClass=QB%23D%23Z%23T%23K%23QT%23&includeStudent=00&seatTypeAndNum=&orderRequest.start_time_str=00%3A00--24%3A00");
		}
		catch (ClientProtocolException e)
		{
			e.printStackTrace();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
	public void getHTMLProxy()
	{
		try
		{
			HTTPUtils.getHTML("http://dynamic.12306.cn/otsquery/query/queryRemanentTicketAction.do?method=queryLeftTicket&orderRequest.train_date=2012-12-31&orderRequest.from_station_telecode=BJP&orderRequest.to_station_telecode=WHN&orderRequest.train_no=&trainPassType=QB&trainClass=QB%23D%23Z%23T%23K%23QT%23&includeStudent=00&seatTypeAndNum=&orderRequest.start_time_str=00%3A00--24%3A00","172.16.251.58",3128);
		}
		catch (ClientProtocolException e)
		{
			e.printStackTrace();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
	public void testEncode(){
		try{
			String str = "武昌";
			String a="%E5%8C%97%E4%BA%AC";
			String name=URLEncoder.encode(str, "UTF-8");
			System.out.println(name);
			System.out.println(java.net.URLDecoder.decode(a, "UTF-8"));
		}catch(Exception ex){
			
		}
	}
}
